//This class interprets a string as a rule

package it.uniroma2.orchestrator.rule;

import it.uniroma2.gestoreontologie.Gestore;

public class RuleInterpreter {

	private String rule;
	private Gestore gestore;
	
	public RuleInterpreter(String rule, Gestore gestore){
		
		this.rule = rule;
		this.gestore = gestore;
		
	}
	
	public void interpret(){
		
		String[] splitted = rule.split("->");
		String ifPart = splitted[0];
		String thenPart = splitted[1];
		
		String[] ifState = ifPart.split(",");
		String[] thenState = thenPart.split(",");
		
		this.ifStateParse(ifState);
		
		for(String tmp : thenState){
			System.out.println(tmp);
		}
	}
	
	private boolean ifStateParse(String[] parse){
		
		for(String state : parse){
			this.ifParse(state);
		}
		
		return false;
	}
	
	private boolean ifParse(String parse){
		
		//Check of it is a not
		boolean not = false;
		if(parse.contains("!")){
			not = true;
			parse = parse.trim();
			parse = parse.substring(1);
		}
		
		//Check if is a relation or a class
		
		//Relation
		if(parse.contains(";")){
			
			String relation = parse.split("\\(")[0];
			String firstElement = parse.split("\\(")[1].split(";")[0];
			String secondElement = parse.split("\\(")[1].split(";")[1];
			secondElement = secondElement.split("\\)")[0];
			
			//3 cases: rel(*;something) or rel(something;*) or rel(some;some)
			
		} else {
			//class
			
		}
		
		
		
		return false;
	}
	
}
